<?php
namespace app\admin\model;
use think\Model;
use think\Db;

/**
 * 重发配置
 * @package app\admin\model
 */
class BusPlatResendConfig extends Model
{
    public function getList($request)
    {
        $data = $this->alias('cf')->field('cf.*,pf.platfrom org_platfrom,pf2.platfrom change_platfrom')
            ->join('bus_platfrom pf','cf.plat_id_org = pf.plat_id','LEFT')
            ->join('bus_platfrom pf2','cf.plat_id_change = pf2.plat_id','LEFT');

        // if($request['keyword'])
        // {
        //     $data = $data->where('res.keyword','like','%'.$request['keyword'].'%');
        // }

        $data = $data->order('cf.onoff desc,cf.create_time desc,cf.id')
            ->paginate($request['limit'], false,['query' => $request])
            ->each(function($item, $key){

                $item->plat_id_org    = $item->plat_id_org . '-' . $item->org_platfrom;
                $item->plat_id_change = $item->plat_id_change . '-' . $item->change_platfrom;

                switch ($item->onoff) {
                    case 0:
                        $item->onoff_ = '<span class="layui-badge-dot"></span>';
                        break;
                    case 1:
                        $item->onoff_ = '<span class="layui-badge-dot layui-bg-green"></span>';
                        break;

                    default:
                        $item->onoff_ = '';
                        break;
                }


            });

            return $data->toarray();
    }
}